package com.neuq.animaladoption.mapper;

import com.neuq.animaladoption.pojo.Animal;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AnimalMapper {
    // 新增动物
    @Insert("insert into animal(animal_name,animal_age,animal_type,variety,animal_pic,shelter_id,create_user,create_time,update_time)" +
            "values(#{animalName},#{animalAge},#{animalType},#{variety},#{animalPic},#{shelterId},#{createUser},#{createTime},#{updateTime})")
    void add(Animal animal);

    List<Animal> list(String animalType, String animalState,Integer shelterId);

    // 获取动物列表
    List<Animal> listLimit(Integer shelterId, String animalType);

    // 根据id查询
    @Select("select * from animal where id=#{id}")
    Animal findById(Integer id);

    // 更新数据
    void update(Animal animal);

    //根据id删除
    @Delete("delete from animal where id=#{id}")
    void deleteById(Integer id);

}
